import { createRouter, createWebHistory,createWebHashHistory } from 'vue-router'
import layout from '../layout/index.vue'
import { md1 } from './modules/md1'
import { md2 } from './modules/md2'
import Cart from '../views/Cart/index.vue'
import CartTop from '../views/Cart/CartTop/index.vue'
import NotFound from '../views/404.vue'
//必有
export const constRoutes = [
  {
    path: '/',
    name: 'home',
    component: layout
  },
  ...md1,
  ...md2,
  {
    path: '/about',
    name: 'about',
    // route level code-splitting
    // this generates a separate chunk (About.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: layout
  },
  {
    path: '/error',
    name: 'error',
    component: NotFound
  }
]
export const asyncRoutes = [
  {
    path: '/asyn1',
    name: 'asyn1',
    component: layout,
    children: [
      {
        path: 'index',
        component: Cart,
        children: [
            {
              path: 'carttop',
              component: CartTop,
              children: [

              ]
            }
        ]
      }
    ]
  }
]//动态添加
export  function filterAsyncRoutes() {//
  return asyncRoutes
}
const router = createRouter({
  history: createWebHashHistory(),
  routes: constRoutes
})

export default router
